/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interface;

import Negocio.CadastroException;
import Persistencia.DAOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

import javax.swing.JOptionPane;


/**
 *
 * @author v3550
 */
public class FConfiguracao extends javax.swing.JInternalFrame {

   
    
    CadastroControlador controlador;
    /**
     * Creates new form FCadUsuario
     */
    public FConfiguracao() throws CadastroException, DAOException, Exception  {
        controlador = new CadastroControlador();
        initComponents();
     
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        Jtabs = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jtextNCategoria = new javax.swing.JTextField();
        jbuttomAddCategoria = new javax.swing.JButton();
        Nome = new javax.swing.JLabel();
        JPainelCategoria = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        Jlistcategorias = new javax.swing.JList();
        jPanel4 = new javax.swing.JPanel();
        jPanelArtigo = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        JListArtigos = new javax.swing.JList();
        jLabel3 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jtextArtDtFim = new javax.swing.JTextField();
        jtextArtHoraFim = new javax.swing.JTextField();
        Nome3 = new javax.swing.JLabel();
        jcbArtUsuario = new javax.swing.JComboBox();
        JBArtigoGravar = new javax.swing.JButton();
        jtextArtNome = new javax.swing.JTextField();
        jtextArtHoraIni = new javax.swing.JTextField();
        jtextArtQtd = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jcbMenuCategoria = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        Nome1 = new javax.swing.JLabel();
        Nome2 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jtextArtDtIni = new javax.swing.JTextField();
        jtextValorInicial = new javax.swing.JTextField();
        Nome4 = new javax.swing.JLabel();
        jcbCriterioVencedor = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jtextUserEmail = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        JBUserGravar = new javax.swing.JButton();
        jtextUserNome = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jPanelUsuario = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        JListUsuarios = new javax.swing.JList();

        setClosable(true);
        setTitle("Configuração");

        jbuttomAddCategoria.setText("Gravar");
        jbuttomAddCategoria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbuttomAddCategoriaActionPerformed(evt);
            }
        });

        Nome.setText("Nome");

        Jlistcategorias.setModel(controlador.getListaCategoria());
        jScrollPane1.setViewportView(Jlistcategorias);

        javax.swing.GroupLayout JPainelCategoriaLayout = new javax.swing.GroupLayout(JPainelCategoria);
        JPainelCategoria.setLayout(JPainelCategoriaLayout);
        JPainelCategoriaLayout.setHorizontalGroup(
            JPainelCategoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JPainelCategoriaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1)
                .addContainerGap())
        );
        JPainelCategoriaLayout.setVerticalGroup(
            JPainelCategoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JPainelCategoriaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jtextNCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbuttomAddCategoria))
                    .addComponent(Nome))
                .addContainerGap(433, Short.MAX_VALUE))
            .addComponent(JPainelCategoria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(Nome)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtextNCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbuttomAddCategoria))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(JPainelCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(21, Short.MAX_VALUE))
        );

        Jtabs.addTab("Categoria", jPanel2);

        JListArtigos.setModel(controlador.getListaArtigo());
        jScrollPane2.setViewportView(JListArtigos);

        jLabel3.setText("Data Ini.:");

        jLabel6.setText("Data Fim:");

        jLabel4.setText("Qtd:");

        jtextArtHoraFim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextArtHoraFimActionPerformed(evt);
            }
        });

        Nome3.setText("Usuário:");

        jcbArtUsuario.setModel(controlador.getListaUsuarioCombo());
        jcbArtUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbArtUsuarioActionPerformed(evt);
            }
        });

        JBArtigoGravar.setText("Gravar");
        JBArtigoGravar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBArtigoGravarActionPerformed(evt);
            }
        });

        jtextArtHoraIni.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextArtHoraIniActionPerformed(evt);
            }
        });

        jLabel7.setText("Hora Fim:");

        jcbMenuCategoria.setModel(controlador.getListaCategoriaCombo());

        jLabel5.setText("Hora Ini.:");

        Nome1.setText("Nome Artigo:");

        Nome2.setText("Categoria:");

        jLabel8.setText("Valor Inicial:");

        jtextValorInicial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextValorInicialActionPerformed(evt);
            }
        });

        Nome4.setText("Critério:");

        jcbCriterioVencedor.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Maior Preço", "Menor Preço" }));

        jLabel9.setText("DD/MM/YYYY");

        jLabel10.setText("DD/MM/YYYY");

        jLabel11.setText("00:00:00");

        jLabel12.setText("00:00:00");

        javax.swing.GroupLayout jPanelArtigoLayout = new javax.swing.GroupLayout(jPanelArtigo);
        jPanelArtigo.setLayout(jPanelArtigoLayout);
        jPanelArtigoLayout.setHorizontalGroup(
            jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelArtigoLayout.createSequentialGroup()
                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel6)
                        .addComponent(jLabel3)
                        .addComponent(Nome1)
                        .addComponent(Nome2)
                        .addComponent(Nome3)
                        .addComponent(jLabel4))
                    .addGroup(jPanelArtigoLayout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(Nome4, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelArtigoLayout.createSequentialGroup()
                        .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jcbMenuCategoria, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jtextArtNome, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelArtigoLayout.createSequentialGroup()
                                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jtextArtDtFim, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtextArtQtd, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
                                    .addComponent(jtextArtDtIni))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel8)
                                    .addGroup(jPanelArtigoLayout.createSequentialGroup()
                                        .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel10)
                                            .addComponent(jLabel9))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel7)
                                            .addComponent(jLabel5))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanelArtigoLayout.createSequentialGroup()
                                        .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jtextArtHoraFim, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                                            .addComponent(jtextArtHoraIni))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel11)
                                            .addComponent(jLabel12))
                                        .addGap(5, 5, 5))
                                    .addGroup(jPanelArtigoLayout.createSequentialGroup()
                                        .addComponent(jtextValorInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(JBArtigoGravar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                            .addComponent(jcbArtUsuario, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(246, 246, 246))
                    .addGroup(jPanelArtigoLayout.createSequentialGroup()
                        .addComponent(jcbCriterioVencedor, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(171, 171, 171))))
            .addComponent(jScrollPane2)
        );
        jPanelArtigoLayout.setVerticalGroup(
            jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelArtigoLayout.createSequentialGroup()
                .addGap(9, 9, 9)
                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcbCriterioVencedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Nome4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcbArtUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Nome3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcbMenuCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Nome2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Nome1)
                    .addComponent(jtextArtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelArtigoLayout.createSequentialGroup()
                        .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtextArtDtIni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jtextArtDtFim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10)))
                    .addGroup(jPanelArtigoLayout.createSequentialGroup()
                        .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jtextArtHoraIni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(jtextArtHoraFim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jtextValorInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(JBArtigoGravar)
                        .addComponent(jLabel8))
                    .addGroup(jPanelArtigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jtextArtQtd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel4)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19, 19, 19))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jPanelArtigo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanelArtigo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        Jtabs.addTab("Artigo para Leilão", jPanel4);

        jLabel1.setText("Nome:");

        JBUserGravar.setText("Gravar");
        JBUserGravar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBUserGravarActionPerformed(evt);
            }
        });

        jLabel2.setText("Email:");

        JListUsuarios.setModel(controlador.getListaUsuario());
        jScrollPane3.setViewportView(JListUsuarios);

        javax.swing.GroupLayout jPanelUsuarioLayout = new javax.swing.GroupLayout(jPanelUsuario);
        jPanelUsuario.setLayout(jPanelUsuarioLayout);
        jPanelUsuarioLayout.setHorizontalGroup(
            jPanelUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelUsuarioLayout.createSequentialGroup()
                .addComponent(jScrollPane3)
                .addContainerGap())
        );
        jPanelUsuarioLayout.setVerticalGroup(
            jPanelUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelUsuarioLayout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 52, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanelUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jtextUserNome, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jtextUserEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(10, 10, 10)
                                .addComponent(JBUserGravar)))
                        .addContainerGap(417, Short.MAX_VALUE))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtextUserNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtextUserEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(JBUserGravar))
                .addGap(18, 18, 18)
                .addComponent(jPanelUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        Jtabs.addTab("Usuário", jPanel3);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Jtabs)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Jtabs, javax.swing.GroupLayout.DEFAULT_SIZE, 435, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void JBUserGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBUserGravarActionPerformed
        // TODO add your handling code here:
        try
        {
            if(controlador.cadastrarUsuario(jtextUserNome.getText(), jtextUserEmail.getText()))
            {
              JOptionPane.showMessageDialog(this, "Usuario cadastrado com sucesso.");
              jtextUserNome.setText("");
              jtextUserEmail.setText("");
            }else
                 JOptionPane.showMessageDialog(this, "Não foi possível cadastrar a nova categoria");
        }catch(CadastroException e)
        {
            JOptionPane.showMessageDialog(this, e.getMessage());
        }   
    }//GEN-LAST:event_JBUserGravarActionPerformed

    private void jbuttomAddCategoriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbuttomAddCategoriaActionPerformed
        // TODO add your handling code here:
        try
        {
            if(controlador.cadastrarCategoria(jtextNCategoria.getText()))
            {
                JOptionPane.showMessageDialog(this, "Categoria inserida com sucesso.");
                jtextNCategoria.setText("");
            }else
                 JOptionPane.showMessageDialog(this, "Não foi possível cadastrar a nova categoria");
        }catch(CadastroException e)
        {
            JOptionPane.showMessageDialog(this, e.getMessage());
        }
       
    }//GEN-LAST:event_jbuttomAddCategoriaActionPerformed

    private void jtextArtHoraFimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextArtHoraFimActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtextArtHoraFimActionPerformed

    private void jtextArtHoraIniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextArtHoraIniActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtextArtHoraIniActionPerformed

    private void jcbArtUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbArtUsuarioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcbArtUsuarioActionPerformed

    private void jtextValorInicialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextValorInicialActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtextValorInicialActionPerformed

    private void JBArtigoGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBArtigoGravarActionPerformed
       
        try {
            String idC = "";
            String idU = "";
            if(jcbMenuCategoria.getSelectedIndex() != -1) {
                idC =""+ controlador.getListaCategoriaCombo().getElementAt(jcbMenuCategoria.getSelectedIndex()).getId();
            }
            
            if(jcbArtUsuario.getSelectedIndex() != -1) {
                idU = "" +controlador.getListaUsuarioCombo().getElementAt(jcbArtUsuario.getSelectedIndex()).getId();
            }
            
            
            String Qtd = jtextArtQtd.getText();
            String art = jtextArtNome.getText();
            String dtIni = (jtextArtDtIni.getText());
            String dtFim = (jtextArtDtFim.getText());
            String hrIni = (jtextArtHoraIni.getText());
            String hrFim = (jtextArtHoraFim.getText());
            String vlr   = jtextValorInicial.getText();
            
            String tipoCriterio = (jcbCriterioVencedor.getItemAt(jcbCriterioVencedor.getSelectedIndex()).toString().toUpperCase().equals("MAIOR PREÇO")) ? "S" : "N";
           
            if(controlador.adicionarArtigo(art, idU, idC, Qtd, dtIni, dtFim, hrIni, hrFim, vlr, tipoCriterio))
            {
                JOptionPane.showMessageDialog(this, "Artigo cadastrado com sucesso!");
                jtextArtQtd.setText("");
                jtextArtNome.setText("");
                jtextArtDtIni.setText("");
                jtextArtDtFim.setText("");
                jtextArtHoraIni.setText("");
                jtextArtHoraFim.setText("");
                jtextValorInicial.setText("");
            }else {
                JOptionPane.showMessageDialog(this, "Não foi possível cadastrar o artigo!");
            }
        } catch (CadastroException | DAOException | ParseException e)
        {
             JOptionPane.showMessageDialog(this, e.getMessage());
        }
        
    }//GEN-LAST:event_JBArtigoGravarActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JBArtigoGravar;
    private javax.swing.JButton JBUserGravar;
    private javax.swing.JList JListArtigos;
    private javax.swing.JList JListUsuarios;
    private javax.swing.JPanel JPainelCategoria;
    private javax.swing.JList Jlistcategorias;
    private javax.swing.JTabbedPane Jtabs;
    private javax.swing.JLabel Nome;
    private javax.swing.JLabel Nome1;
    private javax.swing.JLabel Nome2;
    private javax.swing.JLabel Nome3;
    private javax.swing.JLabel Nome4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanelArtigo;
    private javax.swing.JPanel jPanelUsuario;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JButton jbuttomAddCategoria;
    private javax.swing.JComboBox jcbArtUsuario;
    private javax.swing.JComboBox jcbCriterioVencedor;
    private javax.swing.JComboBox jcbMenuCategoria;
    private javax.swing.JTextField jtextArtDtFim;
    private javax.swing.JTextField jtextArtDtIni;
    private javax.swing.JTextField jtextArtHoraFim;
    private javax.swing.JTextField jtextArtHoraIni;
    private javax.swing.JTextField jtextArtNome;
    private javax.swing.JTextField jtextArtQtd;
    private javax.swing.JTextField jtextNCategoria;
    private javax.swing.JTextField jtextUserEmail;
    private javax.swing.JTextField jtextUserNome;
    private javax.swing.JTextField jtextValorInicial;
    // End of variables declaration//GEN-END:variables
}
